package eerbaar.internal.level;

import java.util.ArrayList;
import java.util.List;

import eerbaar.context.IContext;
import eerbaar.level.IState;
import eerbaar.level.IStates;
import eerbaar.shared.message.DebugMsg;
import eerbaar.shared.message.MsgHelper;

public class States implements IStates {

    private final List<IState> states = new ArrayList<IState>();

    @Override
    public void addState(IState state) {

        this.states.add(state);
    }

    @Override
    public IState[] getStates() {

        return this.states.toArray(new IState[] {});
    }

    @Override
    public void start(IContext model) {

        MsgHelper.sendToDefaultReaders(new DebugMsg("States.Start"));

        for (IState a : this.states) {
            a.start(model);
        }
    }

    @Override
    public void stop() {

        MsgHelper.sendToDefaultReaders(new DebugMsg("States.Stop"));

        for (IState a : this.states) {
            a.stop();
        }
    }

}
